#pragma once
#include "DXUTgui.h"
#include "..\Rendering\RenderBaseStruct.h"
#include "..\Modeling\AlgeBSpline.h"

void CALLBACK OnCurve3DGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext );

class Curve3DRender
{
#define IDC_CURVE3D_MIN					200

#define IDC_ISFORESHORTEN				201
#define IDC_BACKCULLINT					202
#define IDC_BACKDIFFERENT				203
#define IDC_GEOMETRICCONSTRAIN_STATIC	204
#define IDC_GEOMETRICCONSTRAIN			205
#define IDC_CONSTANTTERM_STATIC			206
#define IDC_CONSTANTTERM				207
#define IDC_POINTRADIUS_STATIC			208
#define IDC_POINTRADIUS					209
#define	IDC_MCCURVEONLY					210
#define IDC_ENLARGE_STATIC				211
#define IDC_ENLARGE						212
#define IDC_BIGGESTISO_STATIC			213
#define IDC_BIGGESTISO					214
#define IDC_OVERLAPISO_STATIC			215
#define IDC_OVERLAPISO					216
#define IDC_MCCORNER					217

#define IDC_CURVE3D_MAX					299

public:
	Curve3DRender();
	~Curve3DRender();

public:
	//Diag for curve rendering in 3D.
	CDXUTDialog					Curve3DDiag;

	IDirect3DDevice9*			pD3DDev;
	ID3DXEffect*				pPointEffect;
	ID3DXEffect*				pMCPointEffect;


	int							iConstantTerm;
	int							iPointRadius;
	bool						bShowCurve3DDiag;
	bool						bIsForeshorten;
	bool						bBackCulling;
	bool						bBackDifferent;

	bool						bMCCorner;
	//use in MCCurve.fxh.
	bool						bMCCurveOnly;
	//enlarge the iso band from [0 1] to [0 isoEnlarge], or the iso band is small, could cause no so much accurate adjustment.
	float fIsoEnlarge;
	//iso over biggestIso is not an edge any more.
	float fBiggestIso;
	//iso below the OverlapIso could be one overlap band edge. 
	float fOverlapIso;

public:
	void CreateGUI(CDXUTDialogResourceManager* pManager);
	HRESULT OnCreateDevice( LPDIRECT3DDEVICE9 pd3dDevice );
	void SetGUILocationSize(int locaX, int locaY, int sizeX, int sizeY)
	{ Curve3DDiag.SetLocation(locaX, locaY); Curve3DDiag.SetSize(sizeX, sizeY);	}

	void OnRender(float fElapsedTime, IDirect3DStateBlock9* pStateBlock, LPDIRECT3DTEXTURE9 pTexGaussian, ABSSf* pABS, RENDER_PARAM* renderParam);
	bool HandleMessages( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
	HRESULT OnResetDevice(const D3DSURFACE_DESC* pBackBufferSurfaceDesc);
	void OnLostDevice();
};